package javacommon.util;

import java.util.List;

import com.tech15.pub.dao.MsgTipsDao;
import com.tech15.pub.model.MsgTips;
import com.tech15.task.dao.TaskReturnDao;
import com.tech15.task.dao.TaskReturnProcessDao;
import com.tech15.task.dao.TaskSuperDao;
import com.tech15.task.model.TaskReturn;
import com.tech15.task.model.TaskReturnProcess;
import com.tech15.task.model.TaskSuper;

public class TaskJob {
	private TaskReturnDao taskReturnDao;
	private MsgTipsDao msgTipsDao;
	private TaskSuperDao taskSuperDao;
	private TaskReturnProcessDao taskReturnProcessDao;
	
	public void setTaskReturnProcessDao(TaskReturnProcessDao taskReturnProcessDao) {
		this.taskReturnProcessDao = taskReturnProcessDao;
	}

	public void setTaskSuperDao(TaskSuperDao taskSuperDao) {
		this.taskSuperDao = taskSuperDao;
	}

	public void setMsgTipsDao(MsgTipsDao msgTipsDao) {
		this.msgTipsDao = msgTipsDao;
	}
	
	public void setTaskReturnDao(TaskReturnDao taskReturnDao) {
		this.taskReturnDao = taskReturnDao;
	}

	public void doBizTask(){
		List<TaskReturn> trList =  taskReturnDao.searchTimeout();
		List<TaskSuper> superList = taskSuperDao.findAllBy("type","1");
		if(trList != null && trList.size()>0){
			for(TaskReturn tr : trList){
				for(TaskSuper ts : superList){
					TaskReturnProcess trp = new TaskReturnProcess();
					trp.setUserid(ts.getUserid());
					trp.setZt(0);
					trp.setFssj(DateTools.getCurrentTime());
					trp.setTrid(tr.getTrid());
					taskReturnProcessDao.save(trp);
					
					
					MsgTips tips = new MsgTips();
					tips.setBt(tr.getSsly());
					tips.setContent(tr.getSsly());
					tips.setTablename(Notes.taskReturn);
					tips.setTableid(tr.getTrid()+"");
					tips.setZt(0);
					tips.setXxsj(DateTools.getCurrentTime());
					tips.setUserid(ts.getUserid());
					tips.setUrl(Notes.taskReturnUrl+"trid="+tr.getTrid());
					msgTipsDao.save(tips);
					
				}
				tr.setZt(3);
				tr.setCurclr(null);
				taskReturnDao.update(tr);
			}
		}
		
        System.out.println("任务监管处理完成==================");
    }
}
